<template>
    <a-form ref="formRef" :model="form" :label-col="{ span: 3 }" :wrapper-col="{ span: 20 }" autocomplete="off">
        <a-form-item label="消息类型" :rules="rules.type" name="type">
            <dict-radio v-model:value="form.type" dict-code="noticeType" />
        </a-form-item>
        <a-form-item label="标题" :rules="rules.title" name="title">
            <a-input v-model:value="form.title" placeholder="请输入标题" />
        </a-form-item>
        <a-form-item label="摘要" :rules="rules.digest" name="digest">
            <a-textarea v-model:value="form.digest" placeholder="请输入摘要" allow-clear />
        </a-form-item>
        <a-form-item label="截止日期" :rules="rules.deadline" name="deadline">
            <date-picker v-model:value="form.deadline" placeholder="请选择截止日期" date-format="YYYY-MM-DD HH:mm:ss" />
        </a-form-item>
        <a-form-item label="接收用户" :rules="rules.acceptor" name="acceptor">
            <accept-user v-model:value="form.acceptor" />
        </a-form-item>
        <a-form-item label="优先级" :rules="rules.priority" name="priority">
            <dict-radio v-model:value="form.priority" dict-code="priority" />
        </a-form-item>
        <a-form-item label="内容" :rules="rules.content" name="content">
            <Editor v-model:value="form.content" placeholder="请输入内容" />
        </a-form-item>
    </a-form>
</template>
<script setup>
import { reactive, ref } from 'vue'
import { DictRadio, DatePicker, AcceptUser, Editor } from '@iframe/tools/components'
import { useForm } from '@iframe/tools/mixins/FormMixins'

const { validate, getForm, setForm } = useForm()
const formRef = ref()
const form = reactive({})
const rules = reactive({
    type: { required: true, message: '请选择消息类型' },
    title: { required: true, message: '请输入标题' },
    digest: { required: true, message: '请输入摘要' },
    acceptor: { required: true, message: '请选择接口用户' },
    priority: { required: true, message: '请输入优先级' }
})

defineExpose({ validate: validate(formRef), getForm: getForm(form), setForm: setForm(form) })
</script>
